package com.atguigu.webadmin.controller.apartment;


import com.atguigu.common.result.Result;
import com.atguigu.model.pojo.PaymentType;
import com.atguigu.webadmin.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 梅超凡
 * @Date 2024/11/13~10:33
 * @Description 支付方式管理控制层
*/
@Tag(name = "支付方式管理")
@RequestMapping("/admin/payment")
@RestController
@Slf4j
@CrossOrigin
public class PaymentTypeController {


    @Autowired
    private  PaymentTypeService paymentTypeService;


    @Operation(summary = "查询全部支付方式列表")
    @GetMapping("list")
    public Result<List<PaymentType>> listPaymentType() {
        //查询全部支付方式
        List<PaymentType> typeList = paymentTypeService.listPaymentType();
        //返回结果
        return Result.ok(typeList);
    }

    @Operation(summary = "保存或更新支付方式")
    @Parameter(name = "paymentType",description = "支付方式对象",in = ParameterIn.DEFAULT)
    @PostMapping("saveOrUpdate")
    public Result<Object> saveOrUpdatePaymentType(@RequestBody PaymentType paymentType) {
        //更新支付方式
        paymentTypeService.saveOrUpdate(paymentType);
        return Result.ok();
    }

    @Operation(summary = "根据ID删除支付方式")
    @Parameter(name = "id",description = "支付方式id",in = ParameterIn.DEFAULT)
    @DeleteMapping("deleteById")
    public Result<Object> deletePaymentById(@RequestParam Long id) {
        //逻辑删除
        paymentTypeService.deletePaymentById(id);
        return Result.ok();
    }

}















